<template>
  <a-modal
    :title="title"
    :width="800"
    :visible="visible"
    :confirmLoading="confirmLoading"
    @ok="handleOk"
    @cancel="handleCancel"
    cancelText="关闭">
    
    <a-spin :spinning="confirmLoading">

    

  <a-form-item
          :labelCol="labelCol"
          :wrapperCol="wrapperCol"
          label="结算金额"
           >
          <a-input  v-model="this.settlementMoney" />
       
        
        </a-form-item>

    
    </a-spin>
  </a-modal>
</template>

<script>
  import { httpAction } from '@/api/manage'
  import pick from 'lodash.pick'
  import moment from "moment"
import { deleteAction, getAction, putAction, postAction, downFile, getFileAccessHttpUrl } from '@/api/manage'
  export default {
    name: "updatesettlementMoney",
    data () {
      return {
        id:'',
    settlementMoney:'',
        remark:'', //备注
        title:"操作",
        visible: false,
        xianshi:false,
        model: {},
        labelCol: {
          xs: { span: 24 },
          sm: { span: 5 },
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 16 },
        },

        confirmLoading: false,
        form: this.$form.createForm(this),
        validatorRules:{
        },
        url: {
          add: "/Supplier/updatesettlementMoney",
          edit: "/Supplier/updatesettlementMoney",
        },
      }
    },
    created () {
        console.log("看一看传过来的值有没有出现"+this.$route.query.id);
    },
    methods: {
      add () {
        this.edit({});
      },
      edit (record,id) {
        this.id=id
        this.settlementMoney=record;
        this.form.resetFields();
        this.model[0] = Object.assign({}, record);
         // this.model = record;
          console.log("转化了?"+this.model[0]);
        this.visible = true;
        this.$nextTick(() => {
          this.form.setFieldsValue(pick(this.model[0],'userId'))
	  
        });
      },
      close () {
        this.$emit('close');
        this.visible = false;
      },
      handleOk () {
        const that = this;
        // 触发表单验证
        this.form.validateFields((err, values) => {
          if (!err) {
            that.confirmLoading = true;
            let httpurl = '';
            let method = '';
            if(!this.model.id){
              httpurl+=this.url.add;
              method = 'post';
            }else{
              httpurl+=this.url.edit;
               method = 'put';
            }

         
            let formData = Object.assign(this.model, values);
              formData['settlementMoney']=this.settlementMoney;
                 formData['id']=this.id;
            httpAction(httpurl,formData,method).then((res)=>{
              if(res.success){
                that.$message.success(res.message);
                that.$emit('ok');
                this.searchQuery();
              }else{
                that.$message.warning(res.message);
              }
            }).finally(() => {
              that.confirmLoading = false;
              that.close();
            })
          }
        })
      },
      handleCancel () {
        this.close()
      },
    }
  }
</script>

<style scoped>

</style>